<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
</script>
a = 1;

function renderDom() {
    document.getElementById('app').innerHTML = '数据是' + a;
}

function watcher(method) {
    var b = a;
    method.apply();
    return setInterval(function () {
        if (b != a) {
            method.apply();
            b = a;
        }
    }, 1000)
}

watcher(renderDom);
</script>
</body>
</html>